home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 930 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: clamage@Eng.Sun.COM (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: static members as members of a metacla
  5. Date: 01 Apr 1996 11:06:26 PST
  6. Organization: Sun Microsystems Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4jp7st$lbj@engnews1.Eng.Sun.COM>
  9. References: <KANZE.96Mar29114545@gabi.gabi-soft.fr>
  10. Reply-To: clamage@Eng.Sun.COM
  11. NNTP-Posting-Host: isolde.mti.sgi.com
  12. X-Original-Date: 1 Apr 1996 18:39:25 GMT
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMWApM0y4NqrwXLNJAQE5kQIA0AhmZg5WtI6CJbboIHNOrTyIwhoAeh5Q
  15.     wvHrGalrYB7Pl6DYQcb4hTa3Iobpf2MvKwezL4mW6qHqkVvzKKnYNg==
  16.     =MCBe
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article 96Mar29114545@gabi.gabi-soft.fr, kanze@gabi-soft.fr (J. Kanze) writes:
  20. >In article <4jckdc$ad6@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM (Steve
  21. >Clamage) writes:
  22. >
  23. >    [...]
  24. >|> I believe a reasonable solution to the problem of initialization of
  25. >|> non-local static data is not to use non-local static data!
  26. >
  27. >|> Instead of a static data object or static class data member, use a 
  28. >|> function with a local static object.
  29. >    [...]
  30. >|> Only two features are missing, compared to non-local static objects:
  31. >
  32. >|> 1. If you never reference an object, it is never initialized.
  33. >
  34. >But is this guaranteed by the standard anyway?  
  35.  
  36. Assuming a program terminates normally (returning from main or
  37. calling exit), I believe that every non-local static object defined
  38. in a module that is somehow referenced will eventually be intialized.
  39.  
  40.  
  41. >|> 2. The order of destruction remains unspecified. If that is a problem,
  42. >|> possibly the static objects could be of a type which has a do-nothing
  43. >|> destructor and a "destroy" member function which could be called
  44. >|> explicitly at the proper time.
  45. >
  46. >I thought that the order of destruction was the reverse of
  47. >initialization.
  48.  
  49. I believe the current draft says that. Few current implementations
  50. ensure that result, and whether that guarantee will remain in the standard
  51. is under discussion.
  52.  
  53. ---
  54. Steve Clamage, stephen.clamage@eng.sun.com
  55. ---
  56. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  57.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  58.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  59.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  60.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  61. ]
  62.